package tests;
/*
 * Cristopher Claeys
 * 
 * TCSS 360
 * Conference.addReview JUnit Tests
 * November 18, 2011
 * 
 */


import main.Conference;
import main.Manuscript;
import main.Review;

import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;
                                                            

/**
 * 
 * @author Cristopher Claeys
 * @version 11/27/11
 *
 */
public class AddReviewTest extends TestCase{
	
	Manuscript manu_in_conf;
	Conference conf;
	Review review1;
	Review review2;
	
	/**
	 * Initializes objects used in tests.
	 * Holly revised 11/21 to support changes to getManuscript() (returns a copy now) 
	 */
	@Before
	public void setUp() {
		manu_in_conf = new Manuscript();
		conf = new Conference();
		review1 = new Review();
		review2 = new Review();
		conf.addManuscript(manu_in_conf);
	}
	
	/**
	 * Tests adding a review to the conference if the 
	 * manuscript is already in the conference
	 * Holly updated to support changes to Conference Constructor
	 */
	@Test
	public void testManuInConf() {
		assertEquals("Setup did not work", 
					manu_in_conf.getReviews().size(), 0);
		assertEquals("Setup did not work", 
				conf.getManuscripts().size(), 1);
		conf.addReview(manu_in_conf, review1);
		assertEquals("size of list of reviews not " +
				"increased", 
				manu_in_conf.getReviews().size(), 1);
		assertEquals("size of list of manuscripts changed", 
				conf.getManuscripts().size(), 1);
		assertEquals("added review does not match " +
				"contained", 
				manu_in_conf.getReviews().get(0), review1);
		
		//add a second review
		conf.addReview(manu_in_conf, review2);
		assertEquals("size of list of reviews not " +
				"increased", 
				manu_in_conf.getReviews().size(), 2);
		assertEquals("size of list of manuscripts " +
				"changed", conf.getManuscripts().size(), 1);
		assertEquals("added review does not " +
				"match contained", 
				manu_in_conf.getReviews().get(1), review2);
	}//end testManuInConf

}
